Don't use C99 for hex char encoding.
authorrobertl <robertl>
Tue, 29 Aug 2006 16:11:04 +0000 (16:11 +0000)
committerrobertl <robertl>
Tue, 29 Aug 2006 16:11:04 +0000 (16:11 +0000)
Magproto: Issue error on open if we know it's a serial port instead of crashing later.

magproto.c
nmea.c

index 25bf50a7f61b5c5a86147f0d81e0f8e143bf3d75..2efffa97e642cfb9b56b5de9eb8bbdf1f5cfb23d 100644 (file)
@@ -535,6 +535,9 @@ static int terminit(const char *portname, int create_ok) {
                        }
                }
                is_file = 0;
+               if (serial_handle == NULL) {
+                       fatal(MYNAME ": Could not open serial port %s\n", portname);
+               }
                return 1;
        } else {
                /* Does this check for an error? */
@@ -552,7 +555,8 @@ static char *termread(char *ibuf, int size)
        if (is_file) {
                return fgets(ibuf, size, magfile_h);
        } else {
-               int rc = gbser_read_line(serial_handle, ibuf, size, 2000, '\x0a', '\x0d');
+               int rc;
+               rc = gbser_read_line(serial_handle, ibuf, size, 2000, 0x0a, 0x0d);
                if (rc != gbser_OK) {
                        fatal(MYNAME ": Read error\n");
                }
diff --git a/nmea.c b/nmea.c
index d29f4a908eecc231147957b648370a3150ee2cad..b5612aae639e270b13becdc2165c0de3db8e88b5 100644 (file)
--- a/nmea.c
+++ b/nmea.c
@@ -839,7 +839,7 @@ nmea_rd_posn(void)
        for (i = 0; i < 10; i++) {
                int rv;
                ibuf[0] = 0;
-               rv = gbser_read_line(gbser_handle, ibuf, sizeof(ibuf), 2000, '\x0a', '\x0d');
+               rv = gbser_read_line(gbser_handle, ibuf, sizeof(ibuf), 2000, 0x0a, 0x0d);
                if (global_opts.debug_level > 1) {
                        warning( "READ: %s\n", ibuf);
                }